/*
 * Calculator.h
 *
 * Performs all calculations within the system
 *
 * Author: Zachary Masiello
 * Author: Peter-John Rowe
 */

#ifndef CALCULATOR_H_
#define CALCULATOR_H_

#include "SensorInterrupt.h"
#include "LEDLight.h"
#include <time.h>

#define KILOMETERS 1
#define MILES 2

class Calculator
{
public:
	// Constructor
	Calculator(SensorInterrupt *, LEDLight *);
	// Destructor
	virtual ~Calculator();
	// For thread to control calculations
	static void* run(Calculator *);
	// Change calculation mode
	void changeCalcMode();
	// Start/stop calculations
	void changeCalcOnOff();
	// Set measurement units
	void setUnits();
	// Set wheel circumference
	void setCircumference(int);
	// Calculate Distance
	double calculateDistance();
	// Calculate current speed
	double calculateCurrentSpeed(bool);
	// Calculate average speed
	double calculateAverageSpeed();
	// Reset user data
	void dataReset();
	// Reset ALL data
	void fullReset();
	// Get current speed
	double getCurrentSpeed();
	// Get Average Speed
	double getAverageSpeed();
	// Get the distance
	double getDistance();
	// Gets the circumference
	int getCircumference();
	// Gets the units
	int getUnits();
	// Gets the calc mode
	char getCalcMode();
	// Gets the elapsed time
	int getElapsedTime();
	// Increment the tire cirumference
	void incrementTmpTireCircum();
	// Sets the temporary wheel circumference value
	void setTmpAsPerCircum();

private:
	// Calculation mode (auto/manual)
	char calcMode;
	// Calculator status (on/off)
	bool calcOn;
	// Wheel size
	int wheelSize;
	// Units
	int units;
	// Circumference
	int circumference;
	// Wheel motion interrupt
	SensorInterrupt *sensorInterrupt;
	// LED lights
	LEDLight *ledLight;
	// Number of calculations
	int numCalculations;
	// Total speed
	double summationOfSpeeds;
	// Previous distance
	double previousDistance;
	// Status of motion
	bool isMoving;
	// Current speed
	double currentSpeed;
	// Average speed
	double averageSpeed;
	// Current Distance
	double distance;
	// All count
	int allCount;
	// Elapsed time
	double elapsedTime;
	// Start time
	time_t startTime;
	// Number of updates
	int numTimesNoUpdate;
	// Temporary circumference
	int tmpCircumference;
};

#endif /* CALCULATOR_H_ */
